#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    //a^0=a
    //a^a=0
    //a^b^c=a^(b^c)
    int missingNumber(vector<int>& nums)
    {
        int ret = 0;
        for (auto a : nums)ret ^= a;
        for (int i = 0; i <= nums.size(); i++)ret ^= i;
        return ret;
    }
};